<?php
/**
 * CreateTime: 2023/12/13 16:47
 * User:LinQ
 */

namespace App\ApiCall;

use Illuminate\Support\Facades\Http;

abstract class ApiCallBasicAbstract
{

    protected $appId;
    protected $appKey;
    protected $url;
    protected $header = [];
    protected string $requestType = "GET";
    public static ?ApiCallBasicAbstract $instance = null;

    public function __construct($appId,$appKey,$url)
    {
        $this->appId = $appId;
        $this->appKey = $appKey;
        $this->url = $url;
    }

    public function __clone(): void
    {}

    /**
     * 初始化实体
     * @return mixed
     */
    abstract public static function getInstance($appId, $appKey, $url);

    /**
     * 设置请求的type
     * @param $type
     * @return ApiCallBasicAbstract
     */
     public function setRequestType($type){
        $this->requestType = $type;
        return $this;
     }

    /**
     * 设置请求头
     * @param array $header
     * @return ApiCallBasicAbstract
     */
     public function setRequestHeader(array $header){
         $this->header = $header;
         return $this;
     }

    /**
     * 执行方法
     * @return mixed
     */
    abstract function execute($path,$data);

}